<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

namespace suifeng\builder;

final class Bootstrap
{
    /**
     * 按钮。
     */
    public static function button($type, $href, $icon, $content, $title, $outline = false, $pill = false, $class = null, $config = [])
    {
        $type = $type ?: 'primary';
        $class = 'btn btn-' . $type
            . ($outline ? '-outline' : '')
            . ($pill ? ' btn-pill' : '')
            . ($class ? ' ' . $class : '');

        $container = HtmlBuilder::tag('button', [
            'class'     =>  $class,
            'title'     =>  $title,
            'href'      =>  $href,
        ]);

        if ($icon) {
            $container->add(HtmlBuilder::icon($icon));
        }

        $container->add(HtmlBuilder::plain('&nbsp;' . $content));
        return $container;
    }

    /**
     * 标签。
     */
    public static function label($type, $href, $icon, $content, $title, $outline = false, $pill = false, $class = null, $config = [])
    {
        $type = $type ?: 'primary';
        $class = 'label label-' . $type
            . ($outline ? '-outline' : '')
            . ($pill ? ' label-pill' : '')
            . ($class ? ' ' . $class : '');

        $container = HtmlBuilder::tag('label', [
            'class'     =>  $class,
            'title'     =>  $title,
            'href'      =>  $href,
        ]);

        if ($icon) {
            $container->add(HtmlBuilder::icon($icon));
        }

        $container->add(HtmlBuilder::plain($content));
        return $container;
    }
}
